<%--
  Created by IntelliJ IDEA.
  User: Adminis
  Date: 2025/3/20
  Time: 09:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>收藏管理</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/admin/css/bootstrap.min.css">
    <script src="${pageContext.request.contextPath}/admin/js/jquery-2.1.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/admin/js/bootstrap.min.js"></script>
    <style>

        .cus-container {
            width: 1368px;
        }

        #user-add .modal-content {
            padding: 0 20px 20px;
        }

        #user-edit .modal-content {
            padding: 0 20px 20px;
        }

        #user-list td {
            vertical-align: middle;
        }
        b{
            color: red;
        }

    </style>
</head>
<body>

<div class="container cus-container">
    <h3 class="text-center">收藏信息列表</h3>
    <div id="search-user" style="float: left; margin: 10px 0px;">
        <form class="form-inline" action="${pageContext.request.contextPath}/save/selectSave" method="post">
            <div class="form-group">
                <label for="user_name">用户名:</label>
                <input type="text" name="user_name" value="${user_name}" class="form-control" id="user_name" placeholder="请输入关键字">
            </div>
            &nbsp;&nbsp;&nbsp;
            <div class="form-group">
                <label for="route_name">线路名:</label>
                <input type="text" name="route_name" value="${route_name}" class="form-control" id="route_name" placeholder="请输入关键字">
            </div>
            <button type="submit" class="btn btn-default">查询</button>
        </form>
    </div>

    <table class="table table-bordered clearfix" id="user-list">
        <thead>
        <tr class="bg-primary">
            <th><input type="checkbox" id="firstCb"></th>
            <th>收藏序号</th>
            <th>收藏人</th>
            <th>收藏路线</th>
            <th>收藏时间</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${pageInfo.list}" var="save">
            <tr>
                <td><input type="checkbox" class="cb"></td>
                <td>${save.save_id}</td>
                <td>${save.user.user_name}</td>
                <td>${save.route.route_name}</td>
                <td><fmt:formatDate value="${save.save_date}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

    <%--前五后四--%>

    <c:if test="${pageInfo.pages>=10}">
        <c:set var="begin" value="1"></c:set>
        <c:set var="end" value="10"></c:set>
        <c:if test="${pageInfo.pageNum>5}">
            <c:set var="begin" value="${pageInfo.pageNum-4}"></c:set>
            <c:set var="end" value="${pageInfo.pageNum+5}"></c:set>
        </c:if>
        <c:if test="${pageInfo.pageNum+5>pageInfo.pages}">
            <c:set var="begin" value="${pageInfo.pages-9}"></c:set>
            <c:set var="end" value="${pageInfo.pages}"></c:set>
        </c:if>
    </c:if>

    <c:if test="${pageInfo.pages<10}">
        <c:set var="begin" value="1"></c:set>
        <c:set var="end" value="${pageInfo.pages}"></c:set>
    </c:if>

    <!-- 分页导航 -->
    <div>
        <nav style="text-align: center">
            <ul class="pagination">

                <li>
                    <a href="${pageContext.request.contextPath}/save/selectSave?currentPage=1&user_name=${user_name}&route_name=${route_name}">首页</a>
                </li>

                <li>
                    <a href="${pageContext.request.contextPath}/save/selectSave?currentPage=${pageInfo.prePage}&user_name=${user_name}&route_name=${route_name}">&laquo;</a>
                </li>

                <c:forEach begin="${begin}" end="${end}" var="page">
                    <li ${page eq pageInfo.pageNum?"class='active'":''}>
                        <a href="${pageContext.request.contextPath}/save/selectSave?currentPage=${page}&user_name=${user_name}&route_name=${route_name}">${page}</a>
                    </li>
                </c:forEach>

                <li>
                    <a href="${pageContext.request.contextPath}/save/selectSave?currentPage=${pageInfo.nextPage}&user_name=${user_name}&route_name=${route_name}">&raquo;</a>
                </li>

                <li>
                    <a href="${pageContext.request.contextPath}/save/selectSave?currentPage=${pageInfo.pages}&user_name=${user_name}&route_name=${route_name}">尾页</a>
                </li>

            </ul>
        </nav>
        <div style="float: right;">
            <span>当前第<b>${pageInfo.pageNum}</b>页 共<b>${pageInfo.pages}</b>页 共<b>${pageInfo.total}</b>条数据</span>
        </div>
    </div>

</div>


</body>
</html>

